<template>
  <div class="myContainer">
    <template>
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="全部新闻" name="first">
          <el-row>
            <el-col :span="17">
              <el-row v-for="x in tableData" class="myHeight_95px">
                <el-col class="myWidth_140px">
                  <img :src="x.thumbnail||'static/images/tp@3x.png'" alt="" class="myNewsImg"/>
                </el-col>
                <el-col :span="18">
                  <el-col :span="24" class="myNewsTitle">
                    <a :href=x.url target="new">{{x.title}}</a>
                  </el-col>
                  <el-col :span="24" class="myNewsContent">{{x.digest}}</el-col>
                </el-col>
              </el-row>
            </el-col>
          </el-row>
        </el-tab-pane>
        <el-tab-pane label="新闻" name="second">
          <el-row>
            <el-col :span="17">
              <el-row v-for="x in tableData" class="myHeight_95px">
                <el-col class="myWidth_140px">
                  <img :src="x.thumbnail||'static/images/tp@3x.png'" alt="" class="myNewsImg"/>
                </el-col>
                <el-col :span="18">
                  <el-col :span="24" class="myNewsTitle">
                    <a :href=x.url target="new">{{x.title}}</a>
                  </el-col>
                  <el-col :span="24" class="myNewsContent">{{x.digest}}</el-col>
                </el-col>
              </el-row>
            </el-col>
          </el-row>
        </el-tab-pane>
        <el-tab-pane label="通知通告" name="third">
          <el-row>
            <el-col :span="17">
              <el-row v-for="x in tableData" class="myHeight_95px">
                <el-col class="myWidth_140px">
                  <img :src="x.thumbnail||'static/images/tp@3x.png'" alt="" class="myNewsImg"/>
                </el-col>
                <el-col :span="18">
                  <el-col :span="24" class="myNewsTitle">
                    <a :href=x.url target="new">{{x.title}}</a>
                  </el-col>
                  <el-col :span="24" class="myNewsContent">{{x.digest}}</el-col>
                </el-col>
              </el-row>
            </el-col>
          </el-row>
        </el-tab-pane>
      </el-tabs>
    </template>
    <div class="block">                    
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="page_num"
        :page-sizes="[10, 15]"
        :page-size="page_size"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </div>
  </div>
</template>

<style scoped>
  .myContainer{
    background: #fff;
    padding: 10px;
  }
  .myTitleBorderBottom{
    color: #000;
    font-weight: 500;
    font-size: 16px;
    border-bottom: 1px solid #dbdbdb;
  }
  .myBgGreen{
    background: #00c2a9;
    border-color: #00c2a9;
    color: #fff;
    margin-top:2px;
  }
  .myBgGreen:hover{
    background: #33ceba;
  }
  .myTextAlignRight{
    text-align: right;
  }
  .myLineHeight_40px{
    line-height: 40px;
  }
  .myMarginTop_10px{
    margin-top: 10px;
  }
  .myColorRed{
    color: #f00;
  }
  .myTabTitle,.myTabdigest{
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }
  .myNewsImg{
    width: 100%;
    min-width: 100px;
    max-width:126px;
    max-height: 80px;
  }
  .myNewsTitle{
    color: #4e575b;
    font-size: 14px;
    font-weight: 600;
    overflow-x:hidden;
    width: 100%;
    white-space: nowrap;
    text-overflow:ellipsis;
    line-height: 30px;  
  }
  .myNewsContent{
    color: #7e7e7e;
    font-size: 12px;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }
  .myHeight_95px{
    height: 90px;
    padding-bottom: 5px;
    border-bottom: 1px solid #f2f2f2;
    margin-bottom: 5px;
  }
  .myWidth_140px{
    width: 140px;
  }
</style>

<script>
  import { getArticleList, publishUserTypeScope, staffNewsTagList, residentNewsTagList , deleteNews } from "@/api/contentMGT";
  export default {
    data(){
      return{  
        title:"新闻咨询",    
        tableData:[],  
        total:null, //总条数  
        page_num: 1, //当前页码
        page_size: 10, //每页显示多少条 
        kw:"",
        time:"",
        userTypeScope: "",
        publishUserTypeScope: publishUserTypeScope,
        newsTag:"",
        newsTagList:[],
        loading:false,

        activeName:"first",
        type_list:"1,2,3"
      }
    },
    created() {
      document.title=this.title;
      this.onGetNewsList();
    },
    filters: {
      
    },
    methods:{
      handleClick(tab, event) {
        console.log(tab.index);
        if(tab.index==0){
          this.type_list="1,2,3"
        }else{
          this.type_list=tab.index+""
        }
        this.onGetNewsList();
      },
      onGetNewsList(){
      	let vm=this;
      	let params={
	  		is_fuzzy:true,
	  		kw:vm.kw,
	  		type_list:vm.type_list, // 获取新闻
	  		page_num:vm.page_num,
	  		page_size:vm.page_size
      	}
        vm.loading=true;
      	getArticleList(params).then(response => {
      	  let res=response.data;
          console.log(res)  

      	  vm.tableData=res.rows;
          vm.page_size = res.page_size;
          vm.page_num = res.page_num;
          vm.total = res.total;
          vm.loading=false;
      	}).catch(error => {
          vm.loading=false;
      	})
      },	
      handleSizeChange(val) {
        this.page_size = val;
        this.onGetNewsList();
      },
      handleCurrentChange(val) {
        this.page_num = val;
        this.onGetNewsList();
      },
      handleSelectionChange(val) {
      }
    }

  }


</script>



